<?php
/*************************************************************************************
 *
 *	FileName: listsearch.php
 *	Desc    : 
 *	Author  : Seal
 *	Date    : 2010-6-19
 *
 *************************************************************************************/

require_once ( LIB_DIR.'search/abstractsearch.php');
	
class ListSearch extends Search {

    public function ListSearch( $host='127.0.0.1', $port=3312 ) {
        parent::__construct($host, $port);

		 //override some member vars
        $this->m_index = array( "list_index", "list_stemmed" );
    }

    
	protected function initialize() {}
    
    protected function printResult( $res ) {}
    
	protected function printGroupByResult( $res, $groupField ){} 
	
	public function GetHotList( $count )
	{
		$this->m_sphinxClient->SetLimits( 0, $count );
		$this->m_sphinxClient->SetSortMode ( SPH_SORT_EXTENDED, 'response_count desc' );
        $re = $this->doSearchAttributeOnly();
        
        if( $re === false )
        	return false;

        return $this->GetIdsFromRes( $re['matches'] );
	}
	
	public function GetRecommendList( $count ) 
        {
            $this->m_sphinxClient->SetLimits( 0, $count );
            $this->m_sphinxClient->SetSortMode ( SPH_SORT_EXTENDED, 'flower_count desc' );
            $re = $this->doSearchAttributeOnly();

            if( $re === false )
                return false;

            return $this->GetIdsFromRes( $re['matches'] );
        }
	
	public function GetNewList( $count )
	{
            $this->m_sphinxClient->SetLimits( 0, $count );
            $this->m_sphinxClient->SetSortMode ( SPH_SORT_EXTENDED, 'create_time desc' );
            $re = $this->doSearchAttributeOnly();

            if( $re === false )
                    return false;

            return $this->GetIdsFromRes( $re['matches'] );
	}
	
     
}
    
?>